<?php
    // echo DB_HOST;
    // echo DB_NAME;
    //连接数据库
    $conn = mysqli_connect(DB_HOST,DB_USER,DB_PWD,DB_NAME);
    //准备sql语句
    $sql = "SELECT * FROM categories WHERE id != 1";
    //执行sql语句,获得结果集,需要while循环获取数据
    $result = mysqli_query($conn,$sql);
    // //把查询的数据存储在数组中
    // $arr = [];
    //读取查询出的数据
    while($row = mysqli_fetch_assoc($result)){
        $arr[] = $row;//把数据放入数组中
    }
    // print_r($arr);
?>

<div class="header">
    <h1 class="logo"><a href="index.php"><img src="static/assets/img/logo.png" alt=""></a></h1>
    <ul class="nav">
        <?php foreach($arr as $value):?>
            <li><a href="list.php?categoryId=<?php echo $value['id']?>"><i class="fa <?php echo $value['classname']?>"></i><?php echo $value['name'] ?></a>
        <?php endforeach ?>
    <!--<li><a href="list.php"><i class="fa fa-glass"></i>奇趣事</a></li>
        <li><a href="list.php"><i class="fa fa-phone"></i>潮科技</a></li>
        <li><a href="list.php"><i class="fa fa-fire"></i>会生活</a></li>
        <li><a href="list.php"><i class="fa fa-gift"></i>美奇迹</a></li> -->
    </ul>
    <div class="search">
    <form>
        <input type="text" class="keys" placeholder="输入关键字">
        <input type="submit" class="btn" value="搜索">
    </form>
    </div>
    <div class="slink">
    <a href="javascript:;">链接01</a> | <a href="javascript:;">链接02</a>
    </div>
</div>